<#include "../_sys/layout/layout-web-content.ftl"/>
<@head title="登录首页" keywords="登录首页" description="xbdun.com">
<style type="text/css">
*{margin: 0;padding: 0}
body {font-family: 'Lato', Arial, sans-serif;color: #fff;}
div{margin: 0 auto}
div,p{font-family: "微软雅黑";}
ul{margin:0;list-style:none;padding:0;}
a{text-decoration:none;color:#666;cursor:pointer;}
ul li a:hover{color: #ff6c2b}
.top{width: 100%;height: 66px; z-index: 2}
.top_box{width: 1200px;height: 66px;margin-left: auto;margin-right: auto;}
.top_box_left{float: left;width: 63%;height: 66px;}
.top_box_left img{margin-top: 10px}
.top_box_right{float: right;width: 37%;height: 66px;}
.top_box_right ul{display:flex;}
.top_box_right ul li{line-height: 66px;font-size:14px;flex:1;text-align: center;}
.top_box_right ul li a{color:#fff;}
.top_box_right ul li a.selected{color:#ff6c2b}

.bg_body{width: 100%;height:100%;background-size: 100%;min-width: 1200px}
.bg_body .erwei_box{width: 447px;height:455px;text-align: center;margin:30px auto 100px auto;background: url(/images/signIn.png) no-repeat;}
.bg_body .erwei_box .erwei-img{width: 230px;height:230px;margin:115px auto 20px auto;}
.bg_body .erwei_box .erwei-txt{color:#ff6c2b;font-size:14px;}
.bg_body .bottom_box{position: fixed;bottom:0;color:#fff;background: #000;width: 100%;padding:10px 0;text-align: center;filter:alpha(Opacity=80);-moz-opacity:0.5;opacity: 0.5;}
</style>
</@head>
<@body>
	<div class="top" id="_top">
	    <div class="top_box" id="_top_box">
	        <div class="top_box_left" id="_top_box_left">
	            <a href=""><img src="/images/logo_1.png"></a>
	        </div>
	        <div class="top_box_right" id="_top_box_right">
	            <ul>                    
	                <li><a href="http://www.xbdun.com/index" class="selected">企业首页</a></li>  
	                <li><a href="http://www.xbdun.com/case" class="">案例展示</a></li>  
	                <li><a href="http://www.xbdun.com/news" class="">公司动态</a></li>  
	                <li><a href="http://www.xbdun.com/contact" class="">联系我们</a></li>  
	                <li><a href="http://www.xbdun.com/applet" class="">小程序</a></li>  
	            </ul>
	        </div>
	    </div>
	</div>
	<div class="bg_body">
        <div class="erwei_box">
            <img id="saysao" class="erwei-img" onclick="reflushSaoysao()"/>  
            <div class="erwei-txt">小程序扫一扫登录</div>
            <div id="saysao_msg"></div>
        	<a id="saysao_reflush" onclick="reflushSaoysao()" style="display:none">请刷新</a>
        </div>
        <div class="bottom_box">
            <p class="bottom_text">重庆市辛巴达科技联盟有限公司 © 2016-2017&nbsp; www.xbdun.com</p>
        </div>
    </div>
     <!-- 跳转中间层进行校验 -->
     <form action="${cxt}/system/loadding" method="post"><input type="hidden" id="ladding_data" name="data" /></form>
</@body>
<@script>
<script type="text/javascript">
 //二维码平台生成验证码
 var genroScanQr = "${qrUrl}qr/genroScanQr?scanQrKey=${scanQrKey}&nonceStr=${nonceStr}&effectTime=${effectTime}&qrSize=340&width=340&height=340";
 var genroQrCodeKey = "${qrUrl}qr/genroQrCodeKey?scanQrKey=${scanQrKey}&nonceStr=${nonceStr}&timestamp=";
 var ctimestamp = null;
 var _realyQrCode = null;//真实远程生成的二维码明文
 var _retyTimes = 0;//重拾次数
 var _intervaltime = 0;//重复循环调用时间戳
 var _overtime = 0;//二维码过期时间倒计时
 //重新刷新二维码
 function reflushSaoysao(){
 	$("#saysao_reflush").hide();
 	ctimestamp  = Date.parse(new Date());
 	$.ajax({
	    url: genroQrCodeKey+ctimestamp,
	    type: 'post',
	    dataType:'jsonp',
	    jsonpCallback:"fnCallBack",
	    data: {},
	    success:function(reslt){
	       if(reslt){
	 			if(!reslt.success){
	 				_realyQrCode = null;
	 				$("#saysao_msg").text(reslt.subMsg);
	 				$("#saysao_reflush").show();
	 			}else{
	 				_realyQrCode = reslt.data;
	 				$("#saysao").attr("src",genroScanQr+"&timestamp="+ctimestamp+"&scanQrValue="+_realyQrCode);
	 				_overtime = ${effectTime}*60;
	 			}
 			}
	     }
		})
 }
 //循环调用二维码验证是否扫码成功
 function loginValiQr(arg0){
 	 if(!_realyQrCode||(!arg0&&_overtime<=0)){
 	 	$("#saysao_reflush").show();
 	 	return;
 	 }
 	 $("#ladding_data").val("");
 	 $("#saysao_msg").text("");
 	 $.ajax({
	    url: "${cxt}/system/loginVali",
	    type: 'post',
	    data: {qrCode:_realyQrCode},
	    success:function(reslt){
	       if(reslt){
	 			if(!reslt.success){
	 				//是否为 二维码不存在，可能已经过期,请重新生成
	 				if(reslt.code==30010003&&_retyTimes==0){
	 					//重新试一次
	 					_retyTimes++;
	 					setTimeout(function(){loginValiQr(true);},500);
	 					return;
	 				}
	 				$("#saysao_msg").text(reslt.subMsg);
	 				$("#saysao_reflush").show();
	 			}else{
	 				if(reslt.data){
		 				clearInterval(_intervaltime);
		 				$("#ladding_data").val(reslt.data).parent().submit();
	 				}
	 			}
 			}
 			//重拾归零
 			_retyTimes = 0;
	     },
	    error: function(XMLHttpRequest, textStatus, errorThrown) {
	    	_retyTimes = 0;
	    	clearInterval(_intervaltime);
	    	$("#saysao_msg").text("网络异常，无法访问到服务器端");
		}
	})
 }
 
 //延迟300毫秒生成二维码
 setTimeout(function(){reflushSaoysao();},300);
  //倒计时
 setInterval(function(){if(_overtime<=0){return;}_overtime--;},1000);
 //循环调用
 _intervaltime = setInterval(loginValiQr,3000);
</script>
</@script>